home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 11 / CU Amiga Magazine's Super CD-ROM 11 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-06].iso / cucd / graphics / mpimage / si / convertmpimage.c < prev    next >
C/C++ Source or Header  |  1997-02-26  |  15KB  |  544 lines

  1. /* Convert and display images */
  2.  
  3. /* mark@topic.demon.co.uk */
  4. /* mpaddock@cix.compulink.co.uk */
  5.  
  6. /* This is freely distributable */
  7.  
  8. #include <proto/exec.h>
  9. #include <proto/dos.h>
  10. #include <proto/intuition.h>
  11. #include <proto/graphics.h>
  12. #include <proto/utility.h>
  13. #include <proto/locale.h>
  14. extern struct Library *LocaleBase = NULL;
  15.  
  16. #include <dos/dos.h>
  17.  
  18. #include <math.h>
  19.  
  20. /* EGS Stuff    */
  21. #include <egs/clib/egs_protos.h>
  22. #include <egs/pragmas/egs_pragmas.h>
  23.  
  24. #include <egs/clib/egsintui_protos.h>
  25. #include <egs/pragmas/egsintui_pragmas.h>
  26.  
  27. #include <egs/clib/egsgfx_protos.h>
  28. #include <egs/pragmas/egsgfx_pragmas.h>
  29.  
  30. #include <egs/egsintui.h>
  31.  
  32. extern struct Library *EGSIntuiBase    = NULL;
  33. extern struct Library *EGSGfxBase    = NULL;
  34. extern struct Library *EGSBase        = NULL;
  35.  
  36. #include <libraries/MPImage.h>
  37. #include <pragmas/MPImage_pragmas.h>
  38. #include <clib/MPImage_protos.h>
  39. #include <dos.h>
  40. #include <string.h>
  41. #include <dos/rdargs.h>
  42.  
  43. #define TEMPLATE "FROM/A,X/N/K,Y/N/K,MINX/N/K,MINY/N/K,MAXX/N/K,MAXY/N/K,PUBSCREEN/K,EGS/S,NOREMAP/S,CLONE/S,TO/K,FORMAT/K,FORCEGREY/S,PALETTE/K,COLOURS/K/N,12BIT/S,LINEAR/S,WHITE0/S,MODENAME/K,NOPROGRESS/S,GUI/S"
  44.  
  45. #define OPT_FILE            0
  46. #define OPT_X                1
  47. #define OPT_Y                2
  48. #define OPT_MINX            3
  49. #define OPT_MINY            4
  50. #define OPT_MAXX            5
  51. #define OPT_MAXY            6
  52. #define OPT_SCREEN        7
  53. #define OPT_EGS            8
  54. #define OPT_NOREMAP        9
  55. #define OPT_CLONE            10
  56. #define OPT_TO                11
  57. #define OPT_FORMAT        12
  58. #define OPT_FORCEGREY    13
  59. #define OPT_PALETTE        14
  60. #define OPT_COLOURS        15
  61. #define OPT_12BIT            16
  62. #define OPT_LINEAR        17
  63. #define OPT_WHITE0        18
  64. #define OPT_MODENAME        19
  65. #define OPT_PROGRESS        20
  66. #define OPT_GUI            21
  67.  
  68. #define OPT_COUNT            22
  69.  
  70. extern long __oslibversion=39;
  71.  
  72. extern long __stack = 16000;
  73.  
  74. struct Library *MPImageBase;
  75.  
  76. const char Version[]="$VER: ConvertMPImage 7.3 (26.2.97)";
  77.  
  78. UBYTE NewMap256[256] = {  1,   2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15,
  79.                                   16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
  80.                                   32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
  81.                                   48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63,
  82.                                   64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79,
  83.                                   80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95,
  84.                                   96, 97, 98, 99,100,101,102,103,104,105,106,107,108,109,110,111,
  85.                                  112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,
  86.                                  128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,
  87.                                  144,145,146,147,148,149,150,151,152,153,154,155,156,157,158,159,
  88.                                  160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,
  89.                                  176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,
  90.                                  192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,
  91.                                  208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,
  92.                                  224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,
  93.                                  240,241,242,243,244,245,246,247,248,249,250,251,252,253,254,255,  0
  94.                                 };
  95. UBYTE NewMap16[16] = {  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14, 15,  0
  96.                             };
  97.  
  98. extern struct Catalog *Catalog=NULL;
  99.  
  100. #define CATCOMP_BLOCK
  101. #define CATCOMP_NUMBERS
  102. #include "Cmessages.h"
  103.  
  104. char
  105. *GetMessage(UWORD message) {
  106.     LONG   *l;
  107.     UWORD  *w;
  108.     STRPTR  builtIn;
  109.  
  110.    l = (LONG *)CatCompBlock;
  111.  
  112.     while (*l != message)  {
  113.         w = (UWORD *)((ULONG)l + 4);
  114.         l = (LONG *)((ULONG)l + (ULONG)*w + 6);
  115.     }
  116.     builtIn = (STRPTR)((ULONG)l + 6);
  117.     return(GetCatalogStr(Catalog,message,builtIn));
  118. }
  119.  
  120. int
  121. main(int argc,char **argv) {
  122.     BOOL FromWB = FALSE;
  123.     struct RDArgs *rdargs = NULL;
  124.     LONG opts[OPT_COUNT] = {
  125.         0
  126.     };
  127.     int resx = RETURN_OK;
  128.     struct EasyStruct es = {
  129.         sizeof(struct EasyStruct),
  130.         0,
  131.         "ConvertMPImage",
  132.         NULL,
  133.         NULL
  134.     };
  135.     struct MPImage *MPi;
  136.     struct Screen *screen;
  137.     struct Window *win;
  138.     struct IntuiMessage *msg;
  139.     BOOL done;
  140.     struct EI_NewWindow    EGS_NewWindow = {0};    // EGS New window
  141.     struct EI_Window        *EGS_Win;                // EGS Window
  142.     struct EI_EIntuiMsg     *EGSmsg;                    // Message from the EGS windows
  143.     ULONG newx=0,newy=0;
  144.  
  145.     LocaleBase = OpenLibrary("locale.library",38);
  146.     if (!LocaleBase) {
  147.         if (FromWB) {
  148.             es.es_TextFormat = "Error Opening locale.library(38)";
  149.             EasyRequestArgs(NULL,&es,NULL,NULL);
  150.         }
  151.         else {
  152.             Printf("Error Opening locale.library(38)");
  153.             Printf("\n");
  154.         }
  155.         return RETURN_FAIL;
  156.     }
  157.     Catalog = OpenCatalog(NULL,
  158.                                   "mp/convertmpimage.catalog",
  159.                                   TAG_END);
  160.     es.es_GadgetFormat = GetMessage(MSG_OK);
  161.     if (argc == 0) {
  162.         argc = _WBArgc;
  163.         argv = _WBArgv;
  164.         FromWB = TRUE;
  165.         if (argc < 2) {
  166.             es.es_TextFormat = GetMessage(MSG_DOUBLE);
  167.             EasyRequestArgs(NULL,&es,NULL,NULL);
  168.             CloseCatalog(Catalog);
  169.             CloseLibrary(LocaleBase);
  170.             return RETURN_WARN;
  171.         }
  172.         opts[OPT_FILE] = (LONG)argv[1];
  173.         
  174.     }
  175.     else {
  176.         if (!(rdargs = ReadArgs((char *)TEMPLATE, opts, NULL))) {
  177.             PrintFault(IoErr(), NULL);
  178.             CloseCatalog(Catalog);
  179.             CloseLibrary(LocaleBase);
  180.             return RETURN_ERROR;
  181.         }
  182.         if (opts[OPT_GUI]) {
  183.             FromWB=TRUE;
  184.         }
  185.     }
  186.     if (MPImageBase = OpenLibrary("MPImage.library",6)) {
  187.         SetMPImageScreen((char *)opts[OPT_SCREEN],opts[OPT_PROGRESS]?0:MPIF_PROGRESS);
  188.         if (opts[OPT_TO] || opts[OPT_FORMAT]) {
  189.             if (MPi=LoadMPImage((UBYTE *)opts[OPT_FILE],NULL,
  190.                                         (opts[OPT_FORCEGREY] ? MPIF_FORCEGREY : MPIF_GREY) |
  191.                                         (opts[OPT_LINEAR] ? MPIF_LINEARGREY : 0))) {
  192.                 if (opts[OPT_MINX]) {
  193.                     if (MPi->Width < *((ULONG *)opts[OPT_MINX])) {
  194.                         newx = *((ULONG *)opts[OPT_MINX]);
  195.                     }
  196.                 }
  197.                 if (opts[OPT_MAXX]) {
  198.                     if (MPi->Width > *((ULONG *)opts[OPT_MAXX])) {
  199.                         newx = *((ULONG *)opts[OPT_MAXX]);
  200.                     }
  201.                 }
  202.                 if (!opts[OPT_MINX] && !opts[OPT_MAXX]) {
  203.                     if (opts[OPT_X]) {
  204.                         newx = *((ULONG *)opts[OPT_X]);
  205.                     }
  206.                 }
  207.                 if (opts[OPT_MINY]) {
  208.                     if (MPi->Height < *((ULONG *)opts[OPT_MINY])) {
  209.                         newy = *((ULONG *)opts[OPT_MINY]);
  210.                     }
  211.                 }
  212.                 if (opts[OPT_MAXY]) {
  213.                     if (MPi->Height > *((ULONG *)opts[OPT_MAXY])) {
  214.                         newy = *((ULONG *)opts[OPT_MAXY]);
  215.                     }
  216.                 }
  217.                 if (!opts[OPT_MINY] && !opts[OPT_MAXY]) {
  218.                     if (opts[OPT_Y]) {
  219.                         newy = *((ULONG *)opts[OPT_Y]);
  220.                     }
  221.                 }
  222.                 if (newx || newy) {
  223.                     if (!newx) {
  224.                         newx = MPi->Width;
  225.                     }
  226.                     if (!newy) {
  227.                         newy = MPi->Height;
  228.                     }
  229.                     if (!RescaleMPImage(MPi,newx,newy)) {
  230.                         if (FromWB) {
  231.                             es.es_TextFormat = MPImageErrorMessage();
  232.                             EasyRequestArgs(NULL,&es,NULL,NULL);
  233.                         }
  234.                         else {
  235.                             Printf(MPImageErrorMessage());
  236.                             Printf("\n");
  237.                         }
  238.                         resx = RETURN_FAIL;
  239.                     }
  240.                 }
  241.                 if (!resx) {
  242.                     UBYTE *GreyMap = NULL;
  243.                     if (opts[OPT_WHITE0]) {
  244.                         if (!opts[OPT_FORMAT] || !stricmp((UBYTE *)opts[OPT_FORMAT],MPI_BW16)) {
  245.                             GreyMap = NewMap16;
  246.                         }
  247.                         else {
  248.                             if (!stricmp((UBYTE *)opts[OPT_FORMAT],MPI_BW256)) {
  249.                                 GreyMap = NewMap256;
  250.                             }
  251.                         }
  252.                     }
  253.                     if (!SaveMPImage((UBYTE *)opts[OPT_TO],
  254.                                         MPi->Red, MPi->Green, MPi->Blue,
  255.                                         MPi->Width, MPi->Height,
  256.                                         MPIS_MODENAME,opts[OPT_MODENAME],
  257.                                         MPIS_FORMAT,opts[OPT_FORMAT],
  258.                                         MPIS_PALETTE,opts[OPT_PALETTE],
  259.                                         opts[OPT_COLOURS]?MPIS_COLOURS:TAG_IGNORE,opts[OPT_COLOURS] ? *((ULONG *)opts[OPT_COLOURS]) : 0,
  260.                                         MPIS_12BIT, opts[OPT_12BIT],
  261.                                         MPIS_LINEAR, opts[OPT_LINEAR],
  262.                                         MPIS_GREYMAP, GreyMap,
  263.                                         TAG_END)) {
  264.                         if (FromWB) {
  265.                             es.es_TextFormat = MPImageErrorMessage();
  266.                             EasyRequestArgs(NULL,&es,NULL,NULL);
  267.                         }
  268.                         else {
  269.                             Printf(MPImageErrorMessage());
  270.                             Printf("\n");
  271.                         }
  272.                         resx = RETURN_FAIL;
  273.                     }
  274.                 }
  275.                 FreeMPImage(MPi);
  276.             }
  277.             else {
  278.                 if (FromWB) {
  279.                     es.es_TextFormat = MPImageErrorMessage();
  280.                     EasyRequestArgs(NULL,&es,NULL,NULL);
  281.                 }
  282.                 else {
  283.                     Printf(MPImageErrorMessage());
  284.                     Printf("\n");
  285.                 }
  286.                 resx = RETURN_FAIL;
  287.             }
  288.         }
  289.         else {
  290.             if (opts[OPT_EGS]) {
  291.                 if ((EGSBase = OpenLibrary((char *)"egs.library",0)) &&
  292.                      (EGSGfxBase = OpenLibrary((char *)"egsgfx.library",0)) &&
  293.                     (EGSIntuiBase = OpenLibrary((char *)"egsintui.library", 0))) {
  294.                    screen = NULL;
  295.                     if (MPi=LoadMPImage((UBYTE *)opts[OPT_FILE],screen,MPIF_EGS)) {
  296.                         if (opts[OPT_MINX]) {
  297.                             if (MPi->Width < *((ULONG *)opts[OPT_MINX])) {
  298.                                 newx = *((ULONG *)opts[OPT_MINX]);
  299.                             }
  300.                         }
  301.                         if (opts[OPT_MAXX]) {
  302.                             if (MPi->Width > *((ULONG *)opts[OPT_MAXX])) {
  303.                                 newx = *((ULONG *)opts[OPT_MAXX]);
  304.                             }
  305.                         }
  306.                         if (!opts[OPT_MINX] && !opts[OPT_MAXX]) {
  307.                             if (opts[OPT_X]) {
  308.                                 newx = *((ULONG *)opts[OPT_X]);
  309.                             }
  310.                         }
  311.                         if (opts[OPT_MINY]) {
  312.                             if (MPi->Height < *((ULONG *)opts[OPT_MINY])) {
  313.                                 newy = *((ULONG *)opts[OPT_MINY]);
  314.                             }
  315.                         }
  316.                         if (opts[OPT_MAXY]) {
  317.                             if (MPi->Height > *((ULONG *)opts[OPT_MAXY])) {
  318.                                 newy = *((ULONG *)opts[OPT_MAXY]);
  319.                             }
  320.                         }
  321.                         if (!opts[OPT_MINY] && !opts[OPT_MAXY]) {
  322.                             if (opts[OPT_Y]) {
  323.                                 newy = *((ULONG *)opts[OPT_Y]);
  324.                             }
  325.                         }
  326.                         if (newx || newy) {
  327.                             if (!newx) {
  328.                                 newx = MPi->Width;
  329.                             }
  330.                             if (!newy) {
  331.                                 newy = MPi->Height;
  332.                             }
  333.                             if (!RescaleMPImage(MPi,newx,newy)) {
  334.                                 if (FromWB) {
  335.                                     es.es_TextFormat = MPImageErrorMessage();
  336.                                     EasyRequestArgs(NULL,&es,NULL,NULL);
  337.                                 }
  338.                                 else {
  339.                                     Printf(MPImageErrorMessage());
  340.                                     Printf("\n");
  341.                                 }
  342.                                 resx = RETURN_FAIL;
  343.                             }
  344.                         }
  345.                         if (!resx) {
  346.                             EGS_NewWindow.LeftEdge = 0;
  347.                             EGS_NewWindow.TopEdge = 20;
  348.                             EGS_NewWindow.Width = MPi->Width;
  349.                             EGS_NewWindow.Height = MPi->Height;
  350.                             EGS_NewWindow.MinWidth = 20;
  351.                             EGS_NewWindow.MinHeight = 20;
  352.                             EGS_NewWindow.MaxWidth = MPi->Width;
  353.                             EGS_NewWindow.MaxHeight = MPi->Height;
  354.                             EGS_NewWindow.Screen = NULL;
  355.                             EGS_NewWindow.Bordef.SysGadgets = EI_WINDOWSIZE | EI_WINDOWFRONT | EI_WINDOWFLIP |
  356.                                                                          EI_WINDOWARROWL | EI_WINDOWARROWR | EI_WINDOWARROWU | EI_WINDOWARROWD |
  357.                                                                          EI_WINDOWSCROLLH | EI_WINDOWSCROLLV | EI_WINDOWDRAG |
  358.                                                                          EI_WINDOWCLOSE;
  359.                             EGS_NewWindow.FirstGadgets = NULL;
  360.                             EGS_NewWindow.Title = (char *)opts[OPT_FILE];
  361.                             EGS_NewWindow.Flags = EI_GIMMEZEROZERO | EI_SUPER_BITMAP | EI_WINDOWACTIVE | EI_REPORTMOUSE | EI_QUICKSCROLL | EI_RMBTRAP;
  362.                             EGS_NewWindow.IDCMPFlags = EI_iCLOSEWINDOW;
  363.                             EGS_NewWindow.Port = NULL;
  364.                             EGS_NewWindow.Menu = NULL;
  365.                             EGS_NewWindow.Render = NULL;
  366.                             if (EGS_Win = EI_OpenWindow(&EGS_NewWindow)) {
  367.                                 E_ActivateEGSScreen();
  368.                                 EG_CopyBitMapRastPort(MPi->EGS_BitMap,EGS_Win->RPort,0,0,MPi->Width,MPi->Height,0,0);
  369.                                 done = FALSE;
  370.                                 while    (!done) {
  371.                                     WaitPort(EGS_Win->UserPort);
  372.                                     while (EGSmsg = (struct EI_EIntuiMsg *)GetMsg(EGS_Win->UserPort)) {
  373.                                         switch (EGSmsg->Class) {
  374.                                         case EI_iCLOSEWINDOW:
  375.                                             done = TRUE;
  376.                                             break;
  377.                                         default:
  378.                                             break;
  379.                                         }
  380.                                         ReplyMsg((struct Message *)EGSmsg); 
  381.                                     }
  382.                                 }
  383.                                 EI_CloseWindow(EGS_Win);
  384.                             }
  385.                         }
  386.                         FreeMPImage(MPi);
  387.                     }
  388.                     else {
  389.                         if (FromWB) {
  390.                             es.es_TextFormat = MPImageErrorMessage();
  391.                             EasyRequestArgs(NULL,&es,NULL,NULL);
  392.                         }
  393.                         else {
  394.                             Printf(MPImageErrorMessage());
  395.                             Printf("\n");
  396.                         }
  397.                         resx = RETURN_FAIL;
  398.                     }
  399.                 }
  400.                 if (EGSIntuiBase) {
  401.                     CloseLibrary(EGSIntuiBase);
  402.                 }
  403.                 if (EGSGfxBase) {
  404.                     CloseLibrary(EGSGfxBase);
  405.                 }
  406.                 if (EGSBase) {
  407.                     CloseLibrary(EGSBase);
  408.                 }
  409.             }
  410.             else {
  411.                 if (screen = LockPubScreen((UBYTE *)opts[OPT_SCREEN])) {
  412.                     if (MPi=LoadMPImage((UBYTE *)opts[OPT_FILE],screen,
  413.                                 (opts[OPT_CLONE] ? MPIF_CLONEBITMAP : 0) | 
  414.                                 (opts[OPT_NOREMAP] ? MPIF_NOREMAP : 0))) {
  415.                         if (opts[OPT_MINX]) {
  416.                             if (MPi->Width < *((ULONG *)opts[OPT_MINX])) {
  417.                                 newx = *((ULONG *)opts[OPT_MINX]);
  418.                             }
  419.                         }
  420.                         if (opts[OPT_MAXX]) {
  421.                             if (MPi->Width > *((ULONG *)opts[OPT_MAXX])) {
  422.                                 newx = *((ULONG *)opts[OPT_MAXX]);
  423.                             }
  424.                         }
  425.                         if (!opts[OPT_MINX] && !opts[OPT_MAXX]) {
  426.                             if (opts[OPT_X]) {
  427.                                 newx = *((ULONG *)opts[OPT_X]);
  428.                             }
  429.                         }
  430.                         if (opts[OPT_MINY]) {
  431.                             if (MPi->Height < *((ULONG *)opts[OPT_MINY])) {
  432.                                 newy = *((ULONG *)opts[OPT_MINY]);
  433.                             }
  434.                         }
  435.                         if (opts[OPT_MAXY]) {
  436.                             if (MPi->Height > *((ULONG *)opts[OPT_MAXY])) {
  437.                                 newy = *((ULONG *)opts[OPT_MAXY]);
  438.                             }
  439.                         }
  440.                         if (!opts[OPT_MINY] && !opts[OPT_MAXY]) {
  441.                             if (opts[OPT_Y]) {
  442.                                 newy = *((ULONG *)opts[OPT_Y]);
  443.                             }
  444.                         }
  445.                         if (newx || newy) {
  446.                             if (!newx) {
  447.                                 newx = MPi->Width;
  448.                             }
  449.                             if (!newy) {
  450.                                 newy = MPi->Height;
  451.                             }
  452.                             if (!RescaleMPImage(MPi,newx,newy)) {
  453.                                 if (FromWB) {
  454.                                     es.es_TextFormat = MPImageErrorMessage();
  455.                                     EasyRequestArgs(NULL,&es,NULL,NULL);
  456.                                 }
  457.                                 else {
  458.                                     Printf(MPImageErrorMessage());
  459.                                     Printf("\n");
  460.                                 }
  461.                                 resx = RETURN_FAIL;
  462.                             }
  463.                         }
  464.                         if (!resx) {
  465.                             if (win = OpenWindowTags(NULL,
  466.                                                         WA_CloseGadget, TRUE,
  467.                                                         WA_PubScreen, screen,
  468.                                                         WA_SuperBitMap, MPi->BitMap,
  469.                                                         WA_IDCMP, IDCMP_CLOSEWINDOW,
  470.                                                         WA_InnerWidth, MPi->Width,
  471.                                                         WA_InnerHeight, MPi->Height,
  472.                                                         WA_Title, opts[OPT_FILE],
  473.                                                         WA_DragBar, TRUE,
  474.                                                         WA_NoCareRefresh, TRUE,
  475.                                                         WA_AutoAdjust, TRUE,
  476.                                                         WA_GimmeZeroZero,TRUE,
  477.                                                         TAG_END)) {
  478.                                 done = FALSE;
  479.                                 while    (!done) {
  480.                                     WaitPort(win->UserPort);
  481.                                      while (msg = (struct IntuiMessage *)GetMsg(win->UserPort)) {
  482.                                          switch (msg->Class) {
  483.                                          case IDCMP_CLOSEWINDOW:
  484.                                              // Close window
  485.                                             done = TRUE;
  486.                                              break;
  487.                                          default:
  488.                                              // unknown message
  489.                                              break;
  490.                                              }
  491.                                         ReplyMsg((struct Message *)msg);
  492.                                      }
  493.                                 }    
  494.                                 CloseWindow(win);
  495.                             }
  496.                         }
  497.                         FreeMPImage(MPi);
  498.                     }
  499.                     else {
  500.                         if (FromWB) {
  501.                             es.es_TextFormat = MPImageErrorMessage();
  502.                             EasyRequestArgs(NULL,&es,NULL,NULL);
  503.                         }
  504.                         else {
  505.                             Printf(MPImageErrorMessage());
  506.                             Printf("\n");
  507.                         }
  508.                         resx = RETURN_FAIL;
  509.                     }
  510.                     UnlockPubScreen(NULL,screen);
  511.                 }
  512.                 else {
  513.                     if (FromWB) {
  514.                         es.es_TextFormat = GetMessage(MSG_SCREEN);
  515.                         EasyRequest(NULL,&es,NULL,(UBYTE *)opts[OPT_SCREEN]);
  516.                     }
  517.                     else {
  518.                         Printf(GetMessage(MSG_SCREEN),(UBYTE *)opts[OPT_SCREEN]);
  519.                         Printf("\n");
  520.                     }
  521.                 }
  522.             }
  523.         }
  524.         CloseLibrary(MPImageBase);
  525.     }
  526.     else {
  527.         if (FromWB) {
  528.             es.es_TextFormat = GetMessage(MSG_LIBRARY);
  529.             EasyRequestArgs(NULL,&es,NULL,NULL);
  530.         }
  531.         else {
  532.             Printf(GetMessage(MSG_LIBRARY));
  533.             Printf("\n");
  534.         }
  535.         resx = RETURN_FAIL;
  536.     }
  537.     if (rdargs) {
  538.         FreeArgs(rdargs);
  539.     }
  540.     CloseCatalog(Catalog);
  541.     CloseLibrary(LocaleBase);
  542.     return resx;
  543. }
  544.